/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

*/

#include "videodeviceinformation.h"

class _VideoDeviceInformationPrivate {
  public:
  QString driver;
  QString card;
  QString bus_info;
  quint32 version;
  bool capture;
  bool output;
};

VideoDeviceInformation* VideoDeviceInformation::from(v4l2_capability *capabilities, v4l2_fmtdesc *formats, QObject *parent)
{
  _VideoDeviceInformationPrivate *d=new _VideoDeviceInformationPrivate();
  d->driver=QString((char*) capabilities->driver);
  d->card=QString((char*) capabilities->card);
  d->bus_info=QString((char*) capabilities->bus_info);
  d->version=capabilities->version;
  d->capture=capabilities->capabilities & V4L2_CAP_VIDEO_CAPTURE;
  d->output=capabilities->capabilities & V4L2_CAP_VIDEO_OUTPUT;
  
  // Image Format
  
  return new VideoDeviceInformation(d, parent);
}

QString VideoDeviceInformation::debugInformation() const
{
  QString information;
  information.append("Driver: ").append(d->driver).append("\n");
  information.append("Card: ").append(d->card).append("\n");
  information.append("bus info: ").append(d->bus_info).append("\n");
  information.append("version: ").append(QString::number(d->version)).append("\n");
  information.append("capture: ").append(QString::number(d->capture)).append("\n");
  information.append("output: ").append(QString::number(d->output)).append("\n");
  return information;
}


VideoDeviceInformation::VideoDeviceInformation(_VideoDeviceInformationPrivate* d, QObject* parent): QObject(parent)
{
  this->d=d;
}

VideoDeviceInformation::~VideoDeviceInformation()
{
  delete d;
}

#include "videodeviceinformation.moc"

